package com.liCheng.service.bill;

import com.liCheng.dao.bill.BillMapper;
import com.liCheng.entity.Bill;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("billService")
public class BillServiceImpl implements BillService {

    @Resource
    private BillMapper billMapper;

    public BillMapper getBillMapper() {
        return billMapper;
    }

    public void setBillMapper(BillMapper billMapper) {
        this.billMapper = billMapper;
    }

    /**
     * 模糊查询
     * @param bill
     * @return
     */
    @Override
    public List<Bill> findBill(Bill bill) {
        try {
            return billMapper.getBillTest(bill);//调用DAO方法实现查询
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 添加
     * @param bill
     * @return
     */
    @Override
    public int addBill(Bill bill) {
       try{
           return billMapper.billAdd(bill);
       }catch (Exception e){
           e.printStackTrace();
           throw e;
       }
    }

    /**
     * 修改
     * @param bill
     * @return
     */
    @Override
    public int update(Bill bill) {
        try{
            return billMapper.billUpdate(bill);
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 删除
     * @param bill
     * @return
     */
    @Override
    public int delBill(Bill bill) {
        try{
            return billMapper.billDel(bill);
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
    }
}
